@isTest
private class UpsertContractRESTTest {
    static testMethod void testMethod1() {
        
        Account ma = TestUtils.createAccount();
        ma.Name = '迈克公司';
        ma.RecordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('Maccura', 'Account');
        insert ma;

         Account d = TestUtils.createAccount();
         d.Name = '经销商公司';
         d.AccountNumber = '01';

        d.RecordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('Dealer', 'Account');
        insert d;

         Account a = TestUtils.createAccount();
         a.Name = '终端医院';
        	a.AccountNumber = '01';

        a.RecordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('TerminalCustomer', 'Account');
        insert a;

  
        //创建合同
        Contract__c c = new Contract__c();
        c.Corpcode__c = 'MKSY';
        c.Status__c = '草稿';
        c.Vsalestrucode__c = '05';
        c.Maccura__c = ma.Id;
        c.Account__c  = d.Id;
        c.TerminalCustomer__c = a.Id;
        insert c;

        Map<String,String> cMap = new Map<String,String>();
        cMap.put('Id',c.Id);
      
        Map<String,String> pMap = new Map<String,String>();
        pMap.put('productLine', '生化');
        pMap.put('grade', '一级经销商');
        pMap.put('brand', '四川迈克');
        pMap.put('area', '四川');
        List<Object> pLs = new List<Object>();
        pLs.add(pMap);
       RestReturnMessage message =  UpsertContractREST.UpsertContractREST(EncodingUtil.urlEncode(JSON.serialize(cMap),'UTF-8'), EncodingUtil.urlEncode(JSON.serialize(pLs),'UTF-8'));
       System.debug(message);
        System.debug([select count() from MaccuraAuthorization__c]);

    }
}